package com.ctl.szmd.szmd.feature_wm.ui.fragment

import android.os.Bundle
import android.view.View
import androidx.lifecycle.Observer
import com.ctl.szmd.szmd.feature_wm.R
import com.ctl.szmd.szmd.feature_wm.databinding.FragmentMeBinding
import com.ctl.szmd.szmd.feature_wm.ui.base.BaseWmBindingFragment
import com.ctl.szmd.szmd.feature_wm.ui.viewmodel.MeViewModel
import kotlinx.android.synthetic.main.fragment_me.*
import org.koin.android.viewmodel.ext.android.viewModel


class MeFragment : BaseWmBindingFragment<FragmentMeBinding>() {

    private val viewModel: MeViewModel by viewModel()
    override fun getLayoutId(): Int = R.layout.fragment_me

    override fun initView() {

        binding.apply {
            vm = viewModel
            lifecycle.addObserver(viewModel)
            viewModel.mUserInfo.observe(viewLifecycleOwner, Observer {
                if (it.FulianMyInfoForForApi != null) {
                    model = it.FulianMyInfoForForApi
                }
                refresh_layout.isRefreshing = false
            })
            viewModel.getUserInfo()
            refresh_layout.setOnRefreshListener {
                viewModel.getUserInfo()
            }
        }

    }
}